package models

import "gorm.io/gorm"

type New struct {
	gorm.Model
	Title string `gorm:"type:varchar(100);unique_index" json:"title"`
	Time  string `gorm:"type:varchar(100);unique_index" json:"time"`
	Sort  string `gorm:"type:varchar(100);unique_index" json:"sort"`
}

func (n *New) Add() error {
	return DB.Create(&n).Error
}
func (n *New) List() (new []New, err error) {
	err = DB.Find(&new).Error
	return
}
func (n *New) Del() error {
	return DB.Delete(&n).Error
}

func (n *New) Update() error {
	return DB.Save(&n).Error
}
